import {listFollower,delFollowers } from '../services/follower';

export default {
  namespace: 'follower',

  state: {
    loading: true,
    followerData: {
      errorCode:0,
      msg:"",
      data:{
        pageNo:null,
        pageCount:null,
        total:null,
        pageSize:null,
        latestTime:null,
        list:[]
      },
    },
  },

  effects: {
    *listFollower({ payload,callback }, { call, put }) {
      yield put({
        type: 'changeLoading',
        payload: true,
      });
      const response = yield call(listFollower, payload);
      yield put({
        type: 'changeLoading',
        payload:false,
      });
      callback(response)
    },
    *delFollowers({ payload,callback  }, { call, put }) {
      yield put({
        type: 'changeLoading',
        payload: true,
      });
      const response = yield call(delFollowers, payload);
      yield put({
        type: 'changeLoading',
        payload:false,
      });
      callback(response)
    },
  },

  reducers: {
    listFollowerSuccess(state, action) {
      return {
        ...state,
        followerData: action.payload,
      };
    },
    changeLoading(state, action) {
      return {
        ...state,
        loading: action.payload,
      };
    },


  },
};
